<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Article extends Model
{
    protected $table = 'article';
    protected $guarded = ['id'];
    protected $appends = ['cat_name'];

    public function getCatNameAttribute()
    {
        $coll = ArticleClass::where(['id' => $this->attributes['class_id']])->first();
        if ($coll) {
            return $coll['title'];
        } else {
            return "--";
        }
    }
}
